<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.3.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"example.com","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="Samba配置 - 使每个用户可以用自己的用户名和密码登录自己的home目录修改配置文件1sudo vi &#x2F;etc&#x2F;samba&#x2F;smb.conf 找到[homes]项，此项默认是注释掉的，取消其注释，然后修改其具体内容，修改成如下： 123456789101112131415161718192021222324252627#&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D; Share Definit">
<meta property="og:type" content="article">
<meta property="og:title" content="samba服务配置">
<meta property="og:url" content="http://example.com/2021/01/17/samba%E6%9C%8D%E5%8A%A1%E9%85%8D%E7%BD%AE/index.html">
<meta property="og:site_name" content="解救Z先生">
<meta property="og:description" content="Samba配置 - 使每个用户可以用自己的用户名和密码登录自己的home目录修改配置文件1sudo vi &#x2F;etc&#x2F;samba&#x2F;smb.conf 找到[homes]项，此项默认是注释掉的，取消其注释，然后修改其具体内容，修改成如下： 123456789101112131415161718192021222324252627#&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D; Share Definit">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2021-01-17T07:57:27.000Z">
<meta property="article:modified_time" content="2021-01-17T08:00:01.229Z">
<meta property="article:author" content="greentree">
<meta property="article:tag" content="linux">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://example.com/2021/01/17/samba%E6%9C%8D%E5%8A%A1%E9%85%8D%E7%BD%AE/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>samba服务配置 | 解救Z先生</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">解救Z先生</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/aboutme/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/01/17/samba%E6%9C%8D%E5%8A%A1%E9%85%8D%E7%BD%AE/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="greentree">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="解救Z先生">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          samba服务配置
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2021-01-17 15:57:27 / 修改时间：16:00:01" itemprop="dateCreated datePublished" datetime="2021-01-17T15:57:27+08:00">2021-01-17</time>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h1 id="Samba配置-使每个用户可以用自己的用户名和密码登录自己的home目录"><a href="#Samba配置-使每个用户可以用自己的用户名和密码登录自己的home目录" class="headerlink" title="Samba配置 - 使每个用户可以用自己的用户名和密码登录自己的home目录"></a>Samba配置 - 使每个用户可以用自己的用户名和密码登录自己的home目录</h1><h3 id="修改配置文件"><a href="#修改配置文件" class="headerlink" title="修改配置文件"></a>修改配置文件</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo vi /etc/samba/smb.conf</span><br></pre></td></tr></table></figure>
<p>找到[homes]项，此项默认是注释掉的，取消其注释，然后修改其具体内容，修改成如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash">======================= Share Definitions =======================</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> Un-comment the following (and tweak the other settings below to suit)</span></span><br><span class="line"><span class="meta">#</span><span class="bash"> to <span class="built_in">enable</span> the default home directory shares. This will share each</span></span><br><span class="line"><span class="meta">#</span><span class="bash"> user<span class="string">&#x27;s home directory as \\server\username</span></span></span><br><span class="line">[homes]</span><br><span class="line">   comment = Home Directories</span><br><span class="line">   browseable = yes</span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> By default, the home directories are exported read-only. Change the</span></span><br><span class="line"><span class="meta">#</span><span class="bash"> next parameter to <span class="string">&#x27;no&#x27;</span> <span class="keyword">if</span> you want to be able to write to them.</span></span><br><span class="line">   read only = no</span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> File creation mask is <span class="built_in">set</span> to 0700 <span class="keyword">for</span> security reasons. If you want to</span></span><br><span class="line"><span class="meta">#</span><span class="bash"> create files with group=rw permissions, <span class="built_in">set</span> next parameter to 0775.</span></span><br><span class="line">   create mask = 0755</span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> Directory creation mask is <span class="built_in">set</span> to 0700 <span class="keyword">for</span> security reasons. If you want to</span></span><br><span class="line"><span class="meta">#</span><span class="bash"> create <span class="built_in">dirs</span>. with group=rw permissions, <span class="built_in">set</span> next parameter to 0775.</span></span><br><span class="line">   directory mask = 0755</span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> By default, \\server\username shares can be connected to by anyone</span></span><br><span class="line"><span class="meta">#</span><span class="bash"> with access to the samba server.</span></span><br><span class="line"><span class="meta">#</span><span class="bash"> Un-comment the following parameter to make sure that only <span class="string">&quot;username&quot;</span></span></span><br><span class="line"><span class="meta">#</span><span class="bash"> can connect to \\server\username</span></span><br><span class="line"><span class="meta">#</span><span class="bash"> This might need tweaking when using external authentication schemes</span></span><br><span class="line">   valid users = %S</span><br></pre></td></tr></table></figure>
<h3 id="重启samba服务"><a href="#重启samba服务" class="headerlink" title="重启samba服务"></a>重启samba服务</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">service smbd restart</span><br></pre></td></tr></table></figure>
<h3 id="增加一个现有用户的对应samba帐号"><a href="#增加一个现有用户的对应samba帐号" class="headerlink" title="增加一个现有用户的对应samba帐号"></a>增加一个现有用户的对应samba帐号</h3><p>如我已经有一个用户叫zhaodong，现在给zhaodong开通samba帐号：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo smbpasswd -a zhaodong  </span><br></pre></td></tr></table></figure>
<p>根据提示输入两次密码即可。</p>
<h3 id="在Window下输入samba地址尝试登录"><a href="#在Window下输入samba地址尝试登录" class="headerlink" title="在Window下输入samba地址尝试登录"></a>在Window下输入samba地址尝试登录</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">\\192.168.1.19\zhaodong</span><br></pre></td></tr></table></figure>
<p>此时windows应该会弹出窗口要求输入用户名和密码了</p>
<h3 id="参考实现"><a href="#参考实现" class="headerlink" title="参考实现"></a>参考实现</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">[coresat]</span><br><span class="line">comment = share folder</span><br><span class="line">browseable = yes</span><br><span class="line">path = /home/coresat/</span><br><span class="line">create mask = 0700</span><br><span class="line">directory mask = 0700</span><br><span class="line">valid users = coresat</span><br><span class="line">force user = coresat</span><br><span class="line">force group = coresat</span><br><span class="line">public = yes</span><br><span class="line">available = yes</span><br><span class="line">writable = yes</span><br></pre></td></tr></table></figure>
<h3 id="参考文章"><a href="#参考文章" class="headerlink" title="参考文章"></a>参考文章</h3><p><a target="_blank" rel="noopener" href="https://ubuntu.com/tutorials/install-and-configure-samba#1-overview">https://ubuntu.com/tutorials/install-and-configure-samba#1-overview</a></p>

    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/linux/" rel="tag"># linux</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2021/01/17/%E7%AE%97%E6%B3%95%E5%A4%8D%E6%9D%82%E5%BA%A6/" rel="prev" title="算法复杂度">
      <i class="fa fa-chevron-left"></i> 算法复杂度
    </a></div>
      <div class="post-nav-item">
    <a href="/2021/01/17/ubuntu20-04LTS%E6%9B%B4%E6%8D%A2%E9%98%BF%E9%87%8C%E4%BA%91%E6%BA%90/" rel="next" title="ubuntu20.04LTS更换阿里云源">
      ubuntu20.04LTS更换阿里云源 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#Samba%E9%85%8D%E7%BD%AE-%E4%BD%BF%E6%AF%8F%E4%B8%AA%E7%94%A8%E6%88%B7%E5%8F%AF%E4%BB%A5%E7%94%A8%E8%87%AA%E5%B7%B1%E7%9A%84%E7%94%A8%E6%88%B7%E5%90%8D%E5%92%8C%E5%AF%86%E7%A0%81%E7%99%BB%E5%BD%95%E8%87%AA%E5%B7%B1%E7%9A%84home%E7%9B%AE%E5%BD%95"><span class="nav-number">1.</span> <span class="nav-text">Samba配置 - 使每个用户可以用自己的用户名和密码登录自己的home目录</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%BF%AE%E6%94%B9%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6"><span class="nav-number">1.0.1.</span> <span class="nav-text">修改配置文件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E9%87%8D%E5%90%AFsamba%E6%9C%8D%E5%8A%A1"><span class="nav-number">1.0.2.</span> <span class="nav-text">重启samba服务</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%A2%9E%E5%8A%A0%E4%B8%80%E4%B8%AA%E7%8E%B0%E6%9C%89%E7%94%A8%E6%88%B7%E7%9A%84%E5%AF%B9%E5%BA%94samba%E5%B8%90%E5%8F%B7"><span class="nav-number">1.0.3.</span> <span class="nav-text">增加一个现有用户的对应samba帐号</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%9C%A8Window%E4%B8%8B%E8%BE%93%E5%85%A5samba%E5%9C%B0%E5%9D%80%E5%B0%9D%E8%AF%95%E7%99%BB%E5%BD%95"><span class="nav-number">1.0.4.</span> <span class="nav-text">在Window下输入samba地址尝试登录</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%8F%82%E8%80%83%E5%AE%9E%E7%8E%B0"><span class="nav-number">1.0.5.</span> <span class="nav-text">参考实现</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%8F%82%E8%80%83%E6%96%87%E7%AB%A0"><span class="nav-number">1.0.6.</span> <span class="nav-text">参考文章</span></a></li></ol></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">greentree</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">13</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">3</span>
        <span class="site-state-item-name">标签</span>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">greentree</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  

</body>
</html>
